package com.gitee.randomobject.service.impl;

import com.gitee.randomobject.domain.SysUser;
import com.gitee.randomobject.mapper.UserMapper;
import com.gitee.randomobject.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public void save(SysUser sysUser) {

    }

    @Override
    public List<SysUser> findAll() {
        return null;
    }

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        SysUser sysUser = userMapper.findByName(username);
        return new User(sysUser.getUsername(),sysUser.getPassword(),sysUser.getAuthorities());
    }



}
